﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data;
using IHISCETeim.BLL;
using IHISCETeim.Library;
using IHISCETeim.Model;


namespace IHISCETeim.Web.MachineSys.MacModel
{
    public partial class OUnsuitableProdUpdateSubmit : PageBase
    {
        protected override Permission[] PowerKey
        {
            get
            {
                return new Permission[] { Permission.查看 };
            }
        }
        protected override string DWZRef
        {
            get { return "OUnsuitableProdList"; }
        }


        /// <summary>
        /// 需要修改的ID
        /// </summary>
        protected int UnsuitabledID
        {
            get
            {
                return GetRequestValue<int>("UnsuitabledID",0);
            }
        }

        protected string SubmitJinE
        {
            get
            {
                return obj.SubmitJinE.ToString();
            }
        }

        protected string SubmitDate
        {
            get
            {
                return string.IsNullOrEmpty(obj.SubmitDate) ? DateTime.Now.ToString("yyyy-MM-dd") : obj.SubmitDate;
            }
        }

        private OUnsuitableProdInfo  _obj;
        protected OUnsuitableProdInfo obj
        {
            get
            {
                if (_obj == null)
                {
                    _obj = OUnsuitableProdController.GetById(UnsuitabledID);
                }
                return _obj;
            }
        }


        protected void Page_Load(object sender, EventArgs e)
        {
            if (GetRequestValue<string>("ajaxmethod", "") == "edit")
            {
                addmenu(); 
            }
         
        }


        private void addmenu()
        {
            // UClaimDemageControlInfo obj = Request.SerializableObject<UClaimDemageControlInfo>();
            decimal SubmitJinE = GetRequestValue<decimal>("SubmitJinE", 0);
            string SubmitDate = GetRequestValue<string>("SubmitDate", "");
            this.AddLog(Permission.不适合品处理票_提交金额, obj);

            bool r = OUnsuitableProdController.UpdateSubmit(UnsuitabledID, SubmitJinE, SubmitDate);
            if (r)
                SuccessAlertJson("提交金额成功");
            else
            {
                ErrorJson("提交金额失败", this.DWZRef);
            }
        }
    }
}